<template>
  <div id="prodetails">
    <div class="pic"><img :src="data.img"></div>
    <div class="proMsg">
      <p>{{data.name}}</p>
      <div class="price">
          <p class="now"><span>团购价:</span><span class="nowPrice">{{data.salePoints}}</span><span>元</span></p>
          <p class="original"><span>原价:</span><span>{{data.originPoints}}</span><span>元</span></p>
      </div>
    </div>
    <div class="propic" v-html="data.details">
      
    </div>
    <div class="pro-btn">
      <a href="javascript:;" class="btn-l" @click="routeToTrack((productName = data.name), 'storelist')">门店体验</a>
      <a href="javascript:;" class="btn-r" @click = "routeToUrl((productName = data.name), (url = data.o2o))">O2O下单</a>
    </div>
  </div>
</template>
<script>
  export default {
    name: 'prodetails',
    data () {
      return {
        data: {}
      }
    },
    created () {
      this.showaxios()
    },
    methods: {
      routeToTrack (productName, name) {
        window.zhuge.track('Click', {
          '事件名称': '当月精选-分类-分类详情-商品点击-商品详情-门店体验-点击',
          '访问时间': new Date().toLocaleString(),
          'OpenID': this.getCookie('openid'),
          '商品名称': productName
        }, () => {
          this.routeto(name)
        })
      },
      routeToUrl (productName, url) {
        window.zhuge.track('Click', {
          '事件名称': '当月精选-分类-分类详情-商品点击-商品详情-O2O下单-点击',
          '访问时间': new Date().toLocaleString(),
          'OpenID': this.getCookie('openid'),
          '商品名称': productName
        }, () => {
          window.location.href = url
        })
      },
      showaxios () {
        this.$axios.post(this.apidomain + '/api/productInfo/getProductInfoDetailed/' + this.getCookie('appid'), {
          id: this.$route.query.id
        })
        .then((response) => {
          this.data = response.data.data
        })
        .catch((error) => {
          console.log(error)
        })
      }
    }
  }
</script>
<style lang="less">
  @import "../../assets/less/prodetails/prodetails.less";
</style>
